<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 style="text-align: left;" class="modal-title">付款凭证</h4>
</div>
<form id="files-list-form" action="/xqc/reimburse/paid-trace" method="post" enctype="multipart/form-data">
    <div class="modal-body">
        <div class="row">
            <div class="form-group" style="padding-bottom: 30px;">
                <label style="padding-top: 8px;text-align: right;" class="col-sm-3 control-label">付款凭证</label>
                <div class="col-sm-8">
                    <input type="hidden" id="initial_preview" value="{{json_encode($initialPreview)}}"/>
                    <input type="hidden" id="initial_preview_config" value="{{json_encode($initialPreviewConfig)}}"/>
                    <input type="file" id="paid_file_list" style="margin-top: 4px;" name="source_file" accept=".jpg,.jpeg,.gif,.png,.bmp" required>
                    <span style="text-align: left;" class="help-block"><i class="fa fa-info-circle"></i>&nbsp;文件后缀为.jpg .jpeg .gif .png或.bmp</span>
                </div>
            </div>
            <div class="form-group" style="padding-top: 30px;">
                <div class="col-sm-10" style="margin-left: 10%">
                <span style="color:red;">
                    <div>注：重复上传会覆盖原支付凭证，请谨慎上传。</div>
                </span>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        {{ csrf_field() }}
        <input type="hidden" name="param" value="{{ $id }}">
        <input type="hidden" name="action" value="{{ $paidStatus == 2 ? 'paidChange' : 'paid' }}">
        <button type="submit" class="btn btn-primary" id="labels-submit">提交</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
    </div>
</form>
<script language="JavaScript" type="text/javascript">
    $(function () {
        var getValById = function(id){
            return $.parseJSON($('#'+id).val());
        };
        $("#paid_file_list").fileinput({
            overwriteInitial: true,//不覆盖已存在的图片
            initialPreviewAsData: true,//仅发送预览数据而不是原始标记
            browseLabel: '浏览',
            showRemove: false,
            showUpload: false,
            showCancel: false,
            initialPreview: getValById('initial_preview'),
            initialPreviewConfig: getValById('initial_preview_config'),
        });
        $("#files-list-form").ajaxForm(function (data) {
            if (typeof data === 'object') {
                if (data.status) {
                    $("#myModal").modal('hide');
                    $(".modal-backdrop").remove();
                    $('body').removeClass('modal-open');
                    toastr.success('提交成功 !');
                    $.pjax.reload('#pjax-container');
                } else {
                    swal(data.message, '', 'error');
                }
            }
        });
    });
</script>
